import req from "../../tool/axios"

export interface LoginParams {
    user: string
    pwd: string
}

//登录账号
const Login = (data: LoginParams) => {
    return req.PostJson('/admin/public/login', data, {})
}

export interface RegisterParams {
    code: string
    user: string
    pwd: string
}

//注册账号
const Register = (data: RegisterParams) => {
    return req.PostJson('/admin/public/register', data, {})
}

//刷新token
const RefreshToken = () => {
    return req.GetForm('/admin/public/refresh', {}, {})
}

//获取我的资料并且自动更新token
const Profile = () => {
    return req.GetForm('/admin/user/profile', {}, {})
}

//获取菜单
const Menu = () => {
    return req.GetForm('/admin/user/menu', {}, {})
}

//安全退出
const Logout = () => {
    return req.DeleteForm('/admin/user/logout', {}, {})
}

export interface UpdatePasswordParams {
    user: string
    pwd: string
    new_pwd: string
}

//修改登录密码
const UpdatePassword = (data: UpdatePasswordParams) => {
    return req.PutJson('/admin/user/password', data, {})
}

export default {
    Login, Register, Profile, RefreshToken, Menu, Logout, UpdatePassword
}